package com.yic.module.wms.dal.mysql.warehousearea;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.wms.dal.dataobject.warehousearea.WarehouseAreaDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.wms.controller.admin.warehousearea.vo.*;

/**
 * 库区 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface WarehouseAreaMapper extends BaseMapperX<WarehouseAreaDO> {

    default PageResult<WarehouseAreaDO> selectPage(WarehouseAreaPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseAreaDO>()
                .eqIfPresent(WarehouseAreaDO::getWarehouseId, reqVO.getWarehouseId())
                .likeIfPresent(WarehouseAreaDO::getName, reqVO.getName())
                .eqIfPresent(WarehouseAreaDO::getCode, reqVO.getCode())
                .eqIfPresent(WarehouseAreaDO::getStatus, reqVO.getStatus())
                .orderByDesc(WarehouseAreaDO::getId));
    }

    default List<WarehouseAreaDO> selectList(WarehouseAreaExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WarehouseAreaDO>()
                .eqIfPresent(WarehouseAreaDO::getWarehouseId, reqVO.getWarehouseId())
                .likeIfPresent(WarehouseAreaDO::getName, reqVO.getName())
                .eqIfPresent(WarehouseAreaDO::getCode, reqVO.getCode())
                .eqIfPresent(WarehouseAreaDO::getStatus, reqVO.getStatus())
                .orderByDesc(WarehouseAreaDO::getId));
    }

    default WarehouseAreaDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<WarehouseAreaDO>()
                .eq(WarehouseAreaDO::getCode, code));
    }

    default List<WarehouseAreaDO> selectListByWarehouseId(Long warehouseId) {
        return selectList(new LambdaQueryWrapperX<WarehouseAreaDO>()
                .eq(WarehouseAreaDO::getWarehouseId, warehouseId));
    }

    default List<WarehouseAreaDO> selectList(Collection<Long> ids, Long warehouseId, Collection<Integer> status) {
        return selectList(new LambdaQueryWrapperX<WarehouseAreaDO>()
                .inIfPresent(WarehouseAreaDO::getId, ids)
                .eqIfPresent(WarehouseAreaDO::getWarehouseId, warehouseId)
                .inIfPresent(WarehouseAreaDO::getStatus, status));
    }
}
